package main

import "fmt"

type Countable interface {
	Count() int
}


type Person struct {
	name string
	age int
}

func (p Person) Count() int {
	return p.age
}


type Square struct {
	color string
	side int
}

func (s Square) Count() int {
	return s.side
}

func main() {
	p:=Person{"haha", 21}
	s:=Square{"red", 50}

	counts:=[]Countable{p, s}
	for _, v :=range counts {
		fmt.Println(v.Count());

		if person,ok:=v.(Person); ok {
			fmt.Println(person.name)
		}

		if square,ok:=v.(Square); ok {
			fmt.Println(square.color)
		}
	}
}
